﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Web.WebServiceRef;
using Web.Models;

namespace Web.Controllers
{
    [Authorize]
    public class WebServiceController : Controller
    {
        private WebServiceRef.WebServiceSoapClient proxy;

        public ActionResult Index()
        {

            return View();
        }


        [HttpPost]
        public ActionResult Search(string from, string to, string q)
        {
            UserRepresentation userrep = (UserRepresentation)Session["userrep"];
            proxy = new WebServiceSoapClient("WebServiceSoap");

            try
            {
                List<Web.WebServiceRef.MessageRepresentation> a = new List<Web.WebServiceRef.MessageRepresentation>(proxy.GetMailContaining(userrep.GetId(), Convert.ToDateTime(from), Convert.ToDateTime(to), q));

                return PartialView("_WebserviceCall", a);
            }
            catch
            {
                List<Web.WebServiceRef.MessageRepresentation> a = new List<WebServiceRef.MessageRepresentation>();
                return PartialView("_WebserviceCall", a);
            }
        }





    }
}
